import { doDelete, doGet, doPost, doPut } from "../network/request";

export async function addGoods(goods) {
    return await doPost("/goods/0", goods);
}

export async function deleteGoods(goods) {
    return await doDelete(`/goods/${goods._id}`);
}

export async function updateGoods(goods) {
    console.log("updateGoods", goods);
    let gid = goods._id;
    delete goods._id;
    return await doPut(`/goods/${gid}`, goods);
}

export async function getGoodsByPage(page) {
    const data = await doGet(`/goods/list/${page % 2 === 1 ? 1 : 2}`);
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            // return data;
            resolve(data);
        }, 2000);
    });
}
